﻿using Furion.DynamicApiController;
using IndoorPosition.Server.Core.Utils;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IndoorPosition.Server.Application
{
    /// <summary>
    /// 地理数据相关接口
    /// </summary>
    public class GeoDataAppService:IDynamicApiController
    {
        IGeoDataService _geoDataService;
        public GeoDataAppService(IGeoDataService geoDataService)
        {
            _geoDataService = geoDataService;
        }

        /// <summary>
        /// 保存地理数据（GeoJson）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<FeatureClassMeta> Store(GeoDataInputDto input)
        {
            return await _geoDataService.StoreAsync(input);
        }

        /// <summary>
        /// 数据是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<bool> Exist(string name)
        {
            return await _geoDataService.DataExistAsync(name);
        }

        /// <summary>
        /// 删除表
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task DeleteData(string name)
        {
            await _geoDataService.DeleteDataAsync(name);
        }
    }
}
